<?php if ($this->acl['add']) : ?>
    <a class="ui-state-default ui-corner-all linkButton" href="<?php echo $this->url(array('action' => 'add'), 'devices', true); ?>"><span class="ui-icon ui-icon-plusthick"></span>Add New Device</a>
    <br /><br />
<?php endif; ?>

<table>
    <thead>
        <tr class="ui-widget-header">
            <th>Name</th>
            <th>IP</th>
            <th>Description</th>
            <th>Type</th>
            <th>Status</th>
            <th>Assigned To</th>
            <?php if ($this->acl['edit']) : ?>
            <th>Edit</th>
            <?php endif; ?>
            <?php if ($this->acl['delete']) : ?>
            <th>Delete</th>
            <?php endif; ?>
        </tr>
    </thead>
    <tbody>
        <?php if (count($this->devices) > 0) : ?>
        <?php foreach ($this->devices as $d) : ?>
            <tr class="<?php $this->cycle('row1', 'row2'); ?>">
                <td>
                    <?php if ($this->acl['details']) : ?>
                        <a href="<?php echo $this->url(array('action' => 'details', 'deviceId' => $d['deviceId']), 'devices', true); ?>"><?php echo $d['name']; ?></a>
                    <?php else : ?>
                        <?php echo $d['name']; ?>
                    <?php endif; ?>
                </td>
                <td><?php echo $d['ip']; ?></td>
                <td><?php echo $d['description']; ?></td>
                <td><?php echo $d['typeName']; ?></td>
                <td><?php echo ($d['enabled'] == 1) ? 'Enabled' : 'Disabled'; ?></td>
                <td>
                    <?php if (isset($d['assigned'])) : ?>
                        <a href="<?php echo $this->url(array('action' => 'details', 'slidestreamId' => $d['assigned']['slidestreamId']), 'slidestream', true); ?>"><?php echo $d['assigned']['title']; ?></a>
                    <?php else : ?>
                        Unassigned
                    <?php endif; ?>
                </td>          
                <?php if ($this->acl['edit']) : ?>
                <td>
                    <a class="ui-state-default ui-corner-all linkButtonNoText" href="<?php echo $this->url(array('action' => 'edit', 'deviceId' => $d['deviceId']), 'devices', true); ?>"><span class="ui-icon ui-icon-pencil"></span>&nbsp;</a>
                </td>
                <?php endif; ?>
                <?php if ($this->acl['delete']) : ?>
                <td>
                    <a class="ui-state-default ui-corner-all linkButtonNoText" href="<?php echo $this->url(array('action' => 'delete', 'deviceId' => $d['deviceId']), 'devices', true); ?>"><span class="ui-icon ui-icon-close"></span>&nbsp;</a>
                </td>
                <?php endif; ?>
            </tr>
        <?php endforeach; ?>
        <?php else : ?>
            <tr>
                <td colspan="7">No devices found</td>
            </tr>
        <?php endif; ?>
    </tbody>
</table>